public class Demo11 {
    public static void main(String[] args) throws InterruptedException {
        Thread t =new Thread(()->{
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {

                    break;
                }
            }
            System.out.println("t结束");
        });
       t.start();
       Thread.sleep(3000);
        System.out.println("main线程尝试终止t线程");
       t.interrupt();
    }
}
